home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / T U R B O Language / Turbo Pascal V7.0 / TVDEBUG.ZIP / SHOWEVNT.PAS < prev    next >
Pascal/Delphi Source File  |  1992-10-30  |  2KB  |  104 lines

  1. {************************************************}
  2. {                                                }
  3. {   Turbo Vision Debuging Demo                   }
  4. {   Copyright (c) 1992 by Borland International  }
  5. {                                                }
  6. {************************************************}
  7.  
  8. { This program demonstrates how to use TVDEBUG the debugging
  9.   unit.  By using TVDEBUG your application will create two
  10.   windows on the desktop, an event window and a log window.
  11.   The event window will show all the events as they occur
  12.   in a readable fashion.  The log window intercepts writes
  13.   to Output and displays them in a window.  This allows
  14.   "Writeln" style debugging in Turbo Vision. }
  15.  
  16. program ShowEvnt;
  17.  
  18. {$X+}
  19.  
  20. {$DEFINE DEBUG}
  21.  
  22. {$IFDEF DEBUG}
  23. uses Drivers, Objects, Views, Menus, App, TVDebug;
  24. {$ELSE}
  25. uses Drivers, Objects, Views, Menus, App;
  26. {$ENDIF}
  27.  
  28. type
  29.   PMyWindow = ^TMyWindow;
  30.   TMyWindow = object(TWindow)
  31.     procedure HandleEvent(var Event: TEvent); virtual;
  32.   end;
  33.  
  34. procedure TMyWindow.HandleEvent(var Event: TEvent);
  35. const
  36.   Times: Integer = 0;
  37. begin
  38.   inherited HandleEvent(Event);
  39.  
  40.   if Event.What = evMouseDown then
  41.   begin
  42.     Inc(Times);
  43. {$IFDEF DEBUG}
  44.     Writeln('You clicked in the dummy window (', Times, ')');
  45. {$ENDIF}
  46.   end;
  47. end;
  48.  
  49. type
  50.   PMyApp = ^TMyApp;
  51.   TMyApp = object(TApplication)
  52.     constructor Init;
  53.     procedure InitStatusLine; virtual;
  54.     procedure InitMenuBar; virtual;
  55.   end;
  56. var
  57.   MyApp: TMyApp;
  58.  
  59. constructor TMyApp.Init;
  60. var
  61.   R: TRect;
  62. begin
  63.   inherited Init;
  64.  
  65.   R.Assign(3, 2, 60, 10);
  66.   InsertWindow(New(PMyWindow, Init(R, 'Dummy window', wnNoNumber)));
  67. end;
  68.  
  69. procedure TMyApp.InitStatusLine;
  70. var
  71.   R: TRect;
  72. begin
  73.   GetExtent(R);      
  74.   R.A.Y := R.B.Y - 1;  
  75.   StatusLine := New(PStatusline, Init(R,
  76.    NewStatusDef(0, $FFFF,
  77.      NewStatusKey('~Alt-X~ Exit', kbAltX, cmQuit,
  78.      NewStatusKey('~F4~ New', kbF4, cmNew,
  79.      NewStatusKey('~Alt-F3~ Close', kbAltF3, cmClose,
  80.      NewStatusKey('',kbF10, cmMenu,
  81.      nil)))),
  82.    nil)));
  83. end;
  84.  
  85. procedure TMyApp.InitMenuBar;
  86. var
  87.   R: TRect;
  88. begin
  89.   GetExtent(R);
  90.   R.B.Y:= R.A.Y + 1;
  91.   MenuBar := New(PMenuBar, Init(R, NewMenu(
  92.     NewSubMenu('~F~ile', hcNoContext, NewMenu(
  93.       StdFileMenuItems(nil)),
  94.     NewSubMenu('~W~indow', hcNoContext, NewMenu(
  95.       StdWindowMenuItems(nil)),
  96.       nil)))));
  97. end;
  98.  
  99. begin
  100.   MyApp.Init;
  101.   MyApp.Run;
  102.   MyApp.Done;
  103. end.
  104.